home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 441 / aessrc12 / aesutob3.s < prev    next >
Text File  |  1990-11-23  |  8KB  |  197 lines

  1.  
  2. ;*========================================================================
  3. ;*
  4. ;* AESFAST Public Domain GEM bindings.
  5. ;*
  6. ;*  04/06/89 v1.2
  7. ;*           Added line to objcl_calc() to mask off the upper byte of
  8. ;*           of the object type before going into the 'switch' block.
  9. ;*           This insures that extended object types won't screw up the
  10. ;*           clipping calcs.
  11. ;*
  12. ;*========================================================================
  13.  
  14. ;*************************************************************************
  15. ;*
  16. ;* AESUTOB3.S - Object-related utilities 3 of n.
  17. ;*  Non-standard utility functions.
  18. ;*
  19. ;*************************************************************************
  20.          
  21.           .extern   _objc_offset        ; 
  22.           .include  "gemfast.sh"        ; Pull in header file.
  23.  
  24. ;-------------------------------------------------------------------------
  25. ;       
  26. ; objclX_adjust - Adjust a clipping rectangle.
  27. ;                These functions will expand or contract a clipping 
  28. ;                rectangle (GRECT=objclg_adjust or VRECT=objclv_adjust) 
  29. ;                by a given size.  
  30. ;                
  31. ;                A positive adjustment expands the area, and a negative
  32. ;                adjustment shrinks it.
  33. ;
  34. ;  void obclX_adjust(&rect, horiz_adjust, vert_adjust);
  35. ;-------------------------------------------------------------------------
  36.  
  37. _objclg_adjust::
  38.           moveq.l   #1,d2
  39.           bra.s     objadjust
  40.           
  41. _objcl_adjust::               ; old name retained for compatibility
  42. _objclv_adjust::
  43.  
  44.           moveq.l   #0,d2
  45. objadjust:
  46.           .cargs    #4,.prect.l,.hadj,.vadj
  47.           
  48.           move.l    .prect(sp),a0
  49.           move.w    .hadj(sp),d0
  50.           move.w    .vadj(sp),d1
  51.           sub.w     d0,(a0)+
  52.           sub.w     d1,(a0)+
  53.           tst.w     d2
  54.           beq.s     .no_double
  55.           add.w     d0,d0
  56.           add.w     d1,d1
  57. .no_double:
  58.           add.w     d0,(a0)+
  59.           add.w     d1,(a0)
  60.           rts
  61.                 
  62. ;-------------------------------------------------------------------------
  63. ; objcl_calc - Return clipping rectangle(s) (x,y,w,h & x1,y1,x2,y2) 
  64. ;              from object's coordinates. 
  65. ;
  66. ;  This routine simultaneously calculates the GRECT and VRECT clipping
  67. ;  rectangles that describe an object.   
  68. ;
  69. ;  If object has outside borders or is OUTLINED and/or SHADOWED,
  70. ;  clipping sizes are calc'd accordingly.
  71. ;
  72. ;  (This routine started out short and gracefull...)
  73. ;
  74. ;   void objcl_calc (tree, object, {&grect|NULL},{&vrect|NULL});
  75. ;-------------------------------------------------------------------------
  76.  
  77. _objcl_calc::
  78.  
  79.           .cargs    #-20,.off_x,.off_y,.gx,.gy,.gw,.gh,.vx1,.vy1,.vx2,.vy2
  80.           .cargs    #8,.ptree.l,.obj.w,.pgrect.l,.pvrect.l
  81.  
  82.           link      a6,#-20
  83.           move.l    a2,-(sp)            ; This keeps Laser C happy.
  84.           
  85.           pea       .off_y(a6)          ; First get the screen offsets
  86.           pea       .off_x(a6)          ; of the object via objc_offset.
  87.           move.w    .obj(a6),-(sp)
  88.           move.l    .ptree(a6),-(sp)
  89.           jsr       _objc_offset
  90.           lea       14(sp),sp
  91.  
  92.           move.l    .ptree(a6),a0       ; build a pointer to the object.
  93.           move.w    .obj(a6),d0
  94.           muls      #OBJ_SIZ,d0
  95.           add.l     d0,a0
  96.  
  97.           moveq.l   #0,d1               ; Init adjust val for all sides and
  98.           moveq.l   #0,d2               ; extra adjust for right & bottom.
  99.  
  100.           move.w    ob_type(a0),d0      ; switch (ob_type) 
  101.           and.w     #$00FF,d0           ; mask out any extended object type
  102.           cmp.w     #G_BOX,d0
  103.           beq.s     .box
  104.           cmp.w     #G_IBOX,d0
  105.           beq.s     .box
  106.           cmp.w     #G_BOXCHAR,d0
  107.           beq.s     .box
  108.           cmp.w     #G_BOXTEXT,d0
  109.           beq.s     .text
  110.           cmp.w     #G_FBOXTEXT,d0      ; If the object is not one of these
  111.           beq.s     .text               ; types, it won't have any outer
  112.           cmp.w     #G_BUTTON,d0        ; width, but could still be 
  113.           bne.s     .outline            ; OUTLINED or SHADOWED.
  114. .button:
  115.           subq.w    #1,d1                         ; Any button has an outer
  116.           btst.b    #BEXIT,ob_flags+1(a0)          ; width of at least 1.
  117.           beq.s     .outline                      ; An EXIT button has a
  118.           subq.w    #1,d1                         ; width of 2, and 
  119.           btst.b    #BDEFAULT,ob_flags+1(a0)       ; a DEFAULT EXIT button
  120.           beq.s     .outline                      ; has a width of 3.
  121.           subq.w    #1,d1
  122.           bra.s     .outline
  123. .box:
  124.           move.b    ob_spec+1(a0),d1              ; A box's width is
  125.           ext.w     d1                            ; contained in ob_spec,
  126.           bra.s     .outline                      ; in byte $00nn0000.
  127. .text:
  128.           move.l    ob_spec(a0),a1                ; Width of a text object
  129.           move.w    te_thickness(a1),d1           ; is in the TEDINFO.
  130. .outline:
  131.           move.w    d1,d0                         ; Save true width for
  132.           btst.b    #BOUTLINED,ob_state+1(a0)      ; shadow calcs. If object
  133.           beq.s     .not_outlined                 ; is outlined, the new
  134.           cmp.w     #-3,d1                        ; outer width is -3 unless
  135.           blt.s     .not_outlined                 ; the true width was
  136.           moveq.l   #-3,d1                        ; already bigger.
  137. .not_outlined:
  138.           btst.b    #BSHADOWED,ob_state+1(a0)      ; If object is shadowed
  139.           beq.s     .notshadowed                  ; we need to adjust right
  140.           tst.w     d0                            ; and bottom sides. Rule
  141.           bpl.s     .notnegshadow                 ; for shadow's width is
  142.           neg.w     d0                            ; that the shadow is twice
  143. .notnegshadow:                                    ; the absolute value of
  144.           move.w    d0,d2                         ; the object's width (not
  145.           add.w     d2,d2                         ; counting OUTLINE width).
  146. .notshadowed:
  147.           tst.w     d1                            ; Check accumulated width.
  148.           bmi.s     .outsidewidth                 ; If positive, the object
  149.           moveq.l   #0,d1                         ; has inner width, ignore.
  150. .outsidewidth:
  151.           lea       .gx(a6),a1          ; Get ready to do output.  Get
  152.           move.l    .pgrect(a6),d0      ; pointer to user's GRECT, if null
  153.           beq.s     .nogrect            ; build GRECT into dummy area.
  154.           move.l    d0,a1
  155. .nogrect:
  156.           lea       .vx1(a6),a2         ; Get pointer to user's VRECT,
  157.           move.l    .pvrect(a6),d0      ; if null, build VRECT into dummy
  158.           beq.s     .novrect            ; area.
  159.           move.l    d0,a2
  160. .novrect:
  161.           move.l    .off_x(a6),d0       ; Load the screen x/y we got earlier,
  162.           move.l    d0,(a1)             ; store it all over the place...
  163.           move.l    d0,(a2)
  164.           move.l    d0,4(a2)
  165.           move.w    ob_w(a0),d0
  166.           move.w    d0,4(a1)
  167.           add.w     d0,4(a2)
  168.           move.w    ob_h(a0),d0
  169.           move.w    d0,6(a1)
  170.           add.w     d0,6(a2)
  171.  
  172.           subq.w    #1,d1               ; Subtract one from calc'd size
  173.           add.w     d1,(a1)             ; for clipping, add sizes to
  174.           add.w     d1,(a2)             ; x/y/w/h values in rectangles...
  175.           add.w     d1,2(a1)
  176.           add.w     d1,2(a2)
  177.           addq.w    #1,d1               ; Add the one back in.
  178.           neg.w     d1
  179.           add.w     d1,4(a2)
  180.           add.w     d1,6(a2)
  181.           lsl.w     #1,d1
  182.           addq.w    #1,d1
  183.           add.w     d1,4(a1)
  184.           add.w     d1,6(a1)
  185.  
  186.           add.w     d2,4(a1)            ; Add in shadow sizes to right
  187.           add.w     d2,6(a1)            ; and bottom numbers.
  188.           add.w     d2,4(a2)
  189.           add.w     d2,6(a2)
  190.           
  191.           move.l    (sp)+,a2            ; Restore Laser C register.
  192.           unlk      a6
  193.           rts
  194.  
  195. ;         end of code
  196.  
  197.